﻿@model PessModel.Subject

@{
    ViewBag.Title = "Create";
}

<h2>Create</h2>
<div id="operate">
    @Html.ActionLink("Back", "Index")
</div>
@using (Html.BeginForm()) {
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)

    <fieldset class="create">
        <legend></legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.ActivityID, "Activity")
        </div>
        <div class="editor-field">
            @Html.DropDownList("ActivityID", String.Empty)
            @Html.ValidationMessageFor(model => model.ActivityID)
        </div>
        <div class="editor-label">
            @*@Html.LabelFor(model => model.TrackID)*@Track:
        </div>
        <div class="editor-field">
            <select id="TrackID" name="TrackID"></select>
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Name)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Name)
            @Html.ValidationMessageFor(model => model.Name)
        </div>

        @{/*
        <div class="editor-label">
            @Html.LabelFor(model => model.AllowExpertLeaderSetRules)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.AllowExpertLeaderSetRules)
            @Html.ValidationMessageFor(model => model.AllowExpertLeaderSetRules)
        </div>
        */}
        <div class="editor-btn">
            <input type="submit" value="Create" />
        </div>
    </fieldset>
}




<script type="text/javascript">
    $("#ActivityID").change(function (event) {
        //alert($("#ActivityID").val());
        $.ajax({
            url: "/Subject/GetTracks",
            type: 'POST',
            data: { activityID: $("#ActivityID").val() },
            success: function (tracks) {
                //alert($("#ActivityID").val());
                $('#TrackID').empty();
                //$("#SubjectID").append("<option value='0'>--Select Topic--</option>");
                $.each(tracks, function (i, track) {
                    //alert(topics[i]);
                    $('<option>', { value: track.TrackID }).html(track.Name).appendTo($('#TrackID'));
                });
            }
        });
    });
</script>